var app = getApp();

Page({
  data: {
    canClick:false
  },
  onLoad: function (o) {
    console.log(o), app.setNavigationBarColor(this);
    if (null == o.scene) if (0 < (n = o.arr).indexOf("%")) {
      console.log("包含");
      var e = n.split("%"), t = e[0], i = e[1].slice(2);
      console.log(e), console.log(t), console.log(i);
    } else t = n.split(",")[0], i = n.split(",")[1]; else {
      var n;
      t = (n = o.arr).split(",")[0], i = n.split(",")[1];
    }
    console.log("票券id " + t), console.log("活动发布人id " + i);
    var s = this;

    console.log(this.data);
    app.getUserInfoZ(function (e){
      // console.log(e)
      // wx.showToast({
      //   title: 'sss',
      // })
    })
    app.getUserInfo(function (o) {
      console.log('gui')
      console.log(s.data)
      s.setData({
        user_id: o.id,
        ticket_id: t,
        canClick:true,
      })
      app.util.request({
        url: "entry/wxapp/AddVerification",
        cachetime: "0",
        data: {
          user_id: user_id,
          hx_id: user_id
        },
        success: function (o) {
          console.log(o);
        }
      });
    });
  },
  add_market: function (o) {
    var e = this.data.user_id, t = this.data.ticket_id;
    var ticketId = t
    var userId = e
    // console.log(this.data);
    // return
    console.log(t), console.log(e), app.util.request({
      url: "entry/wxapp/IsHx",
      cachetime: "0",
      data: {
        ticket_id: t,
        user_id: e
      },
      success: function (o) {
        // console.log(o), 1 == o.data ? wx.showToast({
        //   title: "核销成功"
        // }) : wx.showToast({
        //   title: "核销失败"
        // }), setTimeout(function () {
        //   wx.redirectTo({
        //     url: "../index/index"
        //   });
        // }, 1500);
        var duration = 3000
        if (1 == o.data) {
          wx.showToast({
            title: "核销成功",
            duration: duration
          })
          setTimeout(function () {
            wx.redirectTo({
              url: "../index/index"
            });
          }, duration);
        } else {
          wx.showModal({
            title: '提示',
            content: o.data,
          })
        }
      }
    });
  },
  onReady: function () { },
  onShow: function () { },
  onHide: function () { },
  onUnload: function () { },
  onPullDownRefresh: function () { },
  onReachBottom: function () { },
  onShareAppMessage: function () { }
});